<template>
  <div>
    <van-field
      v-model="content"
      :label="label"
      :type="type"
      :placeholder="placeholder"
      :rule="rule"
    />
  </div>
</template>

<script>
export default {
  props: ["label", "type", "placeholder","rule"],
  data() {
    return {
      content: "",
    };
  },
  methods:{
    handelerRule(){
      let rule = new RegExp(this.rule)
      if (rule.test(this.content)) {
        this.$emit("sucessInput",this.content)
      }else{
        this.$emit("sucessInput","")
      }
    }
  },
  watch:{
    content(){
      this.handelerRule();
    }
  }
};
</script>

<style lang="less" scoped></style>
